package com.b2b2c.store.single.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.b2b2c.store.single.entity.StoreSeller;
import com.b2b2c.store.single.logic.StoreSellerLogic;
import com.b2b2c.store.single.service.ILoginService;
import com.b2b2c.until.AjaxMap;
import com.b2b2c.validate.context.CheckParam;


@RestController
@CrossOrigin
public class PublicController {

	@Autowired
	private HttpServletRequest req;
	
	
	@RequestMapping(value="/Public/login", method=RequestMethod.POST)
	public Map<String, ?> getOrderList() {
		
		
		ILoginService<StoreSeller> loginObj = new StoreSellerLogic(req);
		
		CheckParam check = new CheckParam(loginObj.getValidateRule(), loginObj.getMap());
		
		if (!check.checkParam()) {
			return AjaxMap.getInstance(check.getErrorMessage()).getAjaxResultMessage();
		}
		
		Map<String,String> success = loginObj.checkLogin();
		
		if (success == null) {
			return AjaxMap.getInstance(success).getAjaxResultByMap();
		}
		
		
		return AjaxMap.getInstance(success).getAjaxResultByMap();
	}
	
}
